﻿using Newtonsoft.Json;

namespace SCM.Common
{
    /// <summary>
    /// 后端管理平台返回包
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class DataPack<T>
    {
        /// <summary>
        /// 数据内容
        /// </summary>
        [JsonProperty("data")]
        public T Data { get; set; }

        [JsonProperty("code")]
        public ResultCode Code { get; set; } = ResultCode.OK;

        private string message = "";
        [JsonProperty("message")]
        public string Message
        {
            get
            {
                if (string.IsNullOrWhiteSpace(message))
                {
                    message = Code.GetDescription();
                }
                return message;
            }
            set { message = value; }
        }
    }
}
